package com.augn.controller;

import com.augn.entity.Order;
import com.augn.entity.Order;
import com.augn.entity.Result;
import com.augn.service.IOrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Iterator;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author augn
 * @since 2022-09-22
 */
@RestController
@RequestMapping("/order")
public class OrderController {

    @Autowired
    private IOrderService service;

    @PostMapping("/insertOne")
    public Result<?> insertOneOrder(@RequestBody Order order) {
        return service.insertOneOrder(order);
    }

    @DeleteMapping("/deleteOne/{id}")
    public Result<?> deleteOneOrder(@PathVariable Integer id) {
        return service.deleteOneOrder(id);
    }

    @PutMapping("/updateOne")
    public Result<?> updateOneOrder(@RequestBody Order order) {
        return service.updateOneOrder(order);
    }

    @GetMapping("/getOne/{id}")
    public Result<?> getOneOrder(@PathVariable Integer id) {
        return service.getOneOrder(id);
    }

    @PostMapping("/getPart")
    public Result<?> getPartOrder(@RequestBody Order order,
                                  @RequestParam(required = false) Integer pageNum,
                                  @RequestParam(required = false) Integer pageSize) {
        return service.getPartOrder(order,pageNum,pageSize);
    }
}
